//
//  MMStylePropertiesView.m
//  MemeMaker
//
//  Created by dangthan on 7/14/13.
//  Copyright (c) 2013 soyo. All rights reserved.
//

#import "MMStylePropertiesView.h"
#import <QuartzCore/QuartzCore.h>

@implementation MMStylePropertiesView
@synthesize delegate;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.borderColor = [UIColor blackColor].CGColor;
        self.layer.borderWidth = 1.0;
    }
    return self;
}

- (id) initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        self.layer.borderColor = [UIColor blackColor].CGColor;
        self.layer.borderWidth = 1.0;
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    [titleOpacity setText:NSLocalizedString(@"opacity", @"")];
    [titleWidth setText:NSLocalizedString(@"width", @"")];
}

#pragma mark - IBAction method
- (IBAction)opacityDidchanged:(id)sender {
    UISlider *slider = (UISlider *)sender;
    if (delegate && [delegate respondsToSelector:@selector(configOpacity:)]) {
        [delegate configOpacity:slider.value];
    }
    lblOpacity.textAlignment = NSTextAlignmentCenter;
    lblOpacity.text = [NSString stringWithFormat:@"%0.1f", slider.value];
    
}
- (IBAction)widthDidChanged:(id)sender {
    UISlider *slider = (UISlider *)sender;
    if (delegate && [delegate respondsToSelector:@selector(configWidth:)]) {
        [delegate configWidth:slider.value];
    }
    
    lblWidth.textAlignment = NSTextAlignmentCenter;
    lblWidth.text = [NSString stringWithFormat:@"%1.0f", slider.value];
}

@end
